package com.panda.system.controller;

import com.panda.common.annotation.Log;
import com.panda.common.core.controller.BaseController;
import com.panda.common.core.domain.AjaxResult;
import com.panda.common.core.page.TableDataInfo;
import com.panda.common.enums.BusinessType;
import com.panda.common.utils.poi.ExcelUtil;
import com.panda.system.domain.PandaWorkbench;
import com.panda.system.dto.UserTodoReportDto;
import com.panda.system.service.IPandaWorkbenchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 工作台Controller
 * 
 * @author panda
 * @date 2021-01-11
 */
@RestController
@RequestMapping("/resource/workbench")
public class PandaWorkbenchController extends BaseController
{
    @Autowired
    private IPandaWorkbenchService pandaWorkbenchService;

    /**
     * 查询工作台列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PandaWorkbench pandaWorkbench)
    {
        startPage();
        List<PandaWorkbench> list = pandaWorkbenchService.selectPandaWorkbenchList(pandaWorkbench);
        return getDataTable(list);
    }

    /**
     * 导出工作台列表
     */
    @Log(title = "工作台", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PandaWorkbench pandaWorkbench)
    {
        List<PandaWorkbench> list = pandaWorkbenchService.selectPandaWorkbenchList(pandaWorkbench);
        ExcelUtil<PandaWorkbench> util = new ExcelUtil<PandaWorkbench>(PandaWorkbench.class);
        return util.exportExcel(list, "workbench");
    }


    /**
     * 查询工作台列表
     */
    @GetMapping("/queryUserTodoReport")
    public TableDataInfo queryUserTodoReport()
    {
        startPage();
        List<UserTodoReportDto> list = pandaWorkbenchService.queryUserTodoReport();
        return getDataTable(list);
    }


}
